python remove whitespace from start of string

30

sentence = ' hello  apple'
sentence.strip()
>>> 'hello  apple'
'     hello world!    '.strip()
'hello world!'


'     hello world!    '.lstrip()
'hello world!    '

'     hello world!    '.rstrip()
'    hello world!'
>>> "    xyz     ".rstrip()
'    xyz'
>>> s.strip()
'Hello  World   From Pankaj \t\n\r\tHi There'

Comments

Submit
0 Comments